package com.trippin.Utils;

import java.io.Serializable;
import java.util.Comparator;

import com.trippin.DB.entities.AttractionEntity;

public class AttractionEntityComparator implements Comparator<AttractionEntity>, Serializable {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		public int compare(AttractionEntity att0,
				AttractionEntity att1) {
			
			long pluses0 = att0.getPluses();
			long minuses0 = att0.getMinuses();
			long plusMinusDiff0 = pluses0 - minuses0;
			
			long pluses1 = att1.getPluses();
			long minuses1 = att1.getMinuses();
			long plusMinusDiff1 = pluses1 - minuses1;
			
			if((plusMinusDiff0 > 0) && (plusMinusDiff1 < 0)) {
				return 1;
			}
			
			else if((plusMinusDiff1 > 0) && (plusMinusDiff0 < 0)) {
				return -1;
			}
			
			else if(pluses0 > pluses1) {
				return 1;
			}
			
			else if(pluses0 < pluses1) {
				return -1;
			}
			
			else if (minuses0 < minuses1){
				return 1;
			}
			
			else if (minuses0 > minuses1){
				return -1;
			}
			
			else {
				return 1;
			}
			
		}
}
